home *** CD-ROM | disk | FTP | other *** search
/ SunSoft Catalyst CDWARE 1996 May to August / Catalyst CDWARE 1996 May to August.iso / .products / USoft / cgi-bin / support-.pl < prev    next >
Perl Script  |  1996-02-15  |  4KB  |  148 lines

  1. #!/bin/perl 
  2. $datum=`date`;
  3. $sendto='support@usoft.nl';
  4.  
  5. sub ReadParse {
  6.   local (*in) = @_ if @_;
  7.   local ($i, $key, $val);
  8.   # Read in text
  9.   if (&MethGet) {
  10.     $in = $ENV{'QUERY_STRING'};
  11.   } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
  12.     read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  13.   }
  14.   @in = split(/&/,$in);
  15.   foreach $i (0 .. $#in) {
  16.     # Convert plus's to spaces
  17.     $in[$i] =~ s/\+/ /g;
  18.     # Split into key and value.  
  19.     ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
  20.     # Convert %XX from hex numbers to alphanumeric
  21.     $key =~ s/%(..)/pack("c",hex($1))/ge;
  22.     $val =~ s/%(..)/pack("c",hex($1))/ge;
  23.     # Associate key and value
  24.     $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
  25.     $in{$key} .= $val;
  26.   }
  27.   return length($in); 
  28. }
  29. # PrintHeader
  30. # Returns the magic line which tells WWW that we're an HTML document
  31. sub PrintHeader {
  32.   return "Content-type: text/html\n\n";
  33. }
  34. # MethGet
  35. # Return true if this cgi call was using the GET request, false otherwise
  36. sub MethGet {
  37.   return ($ENV{'REQUEST_METHOD'} eq "GET");
  38. }
  39. # MyURL
  40. # Returns a URL to the script
  41. sub MyURL  {
  42.   return  'http://' . $ENV{'SERVER_NAME'} .  $ENV{'SCRIPT_NAME'};
  43. }
  44. # CgiError
  45. # Prints out an error message which which containes appropriate headers,
  46. # markup, etcetera.
  47. # Parameters:
  48. #  If no parameters, gives a generic error message
  49. #  Otherwise, the first parameter will be the title and the rest will 
  50. #  be given as different paragraphs of the body
  51. sub CgiError {
  52.   local (@msg) = @_;
  53.   local ($i,$name);
  54.   if (!@msg) {
  55.     $name = &MyURL;
  56.     @msg = ("Error: script $name encountered fatal error");
  57.   };
  58.   print &PrintHeader;
  59.   print "<html><head><title>$msg[0]</title></head>\n";
  60.   print "<body><h1>$msg[0]</h1>\n";
  61.   foreach $i (1 .. $#msg) {
  62.     print "<p>$msg[$i]</p>\n";
  63.   }
  64.   print "</body></html>\n";
  65. }
  66.  
  67.  
  68. if (&ReadParse(*input)) {
  69.   print &PrintHeader;
  70.   print "<HTML>\n";
  71.   print "<HEAD>\n";
  72.   print "<TITLE>Thank you for using this Support-Request form</TITLE>\n";
  73.   print "</HEAD>\n";
  74.   print "<BODY>\n";
  75.   print "<H1>Thank you for using this Support-Request form<H3>";
  76.   print "The Support-Desk will try to accomodate your request as soon as possible<P>\n";
  77.   print "Request submitted on: $datum<p>";
  78.   print "</BODY>\n";
  79.   print "</HTML>\n";
  80.   }
  81. else {
  82.   print "Something has gone wrong; No request send to USoft Support ($sendto)";
  83.   };
  84.  
  85.  
  86. $reportedby=$input{"reportedby"};
  87. $company=$input{"company"};
  88. $reference=$input{"reference"};
  89. $regno=$input{"regno"};
  90. $phone1=$input{"phone1"};
  91. $phone2=$input{"phone2"};
  92. $fax=$input{"fax"};
  93. $email=$input{"email"};
  94. $city=$input{"city"};
  95. $country=$input{"country"};
  96. $product=$input{"product"};
  97. $pversion=$input{"pversion"};
  98. $ostype=$input{"ostype"};
  99. $osversion=$input{"osversion"};
  100. $computer=$input{"computer"};
  101. $model=$input{"model"};
  102. $dbase=$input{"dbase"};
  103. $dbversion=$input{"dbversion"};
  104. $description=$input{"description"};
  105. $middleware=$input{"middleware"};
  106.  
  107.  
  108.  
  109.  
  110. open (MAIL, "|/cgi-bin/smtpsend");
  111. print MAIL "To: $sendto\n";
  112. print MAIL "From: WWW\@www.usoft.com\n";
  113. print MAIL "Subject: Support Request Form\n\n";
  114. print MAIL "Location: http://www.usoft.com\n\n";
  115. print MAIL "Submitted on: $datum\n";
  116. print MAIL "Reported by : $reportedby\n";
  117. print MAIL "Registration Number: $regno\n";
  118. print MAIL "Company    : $company\n";
  119. print MAIL "City        : $city\n";
  120. print MAIL "Country     : $country\n";
  121. print MAIL "Phone1       : $phone1\n";
  122. print MAIL "Phone2       : $phone2\n";
  123. print MAIL "Fax         : $fax\n";
  124. print MAIL "EMail       : $email\n";
  125. print MAIL "-------------------------------------------------------------------------------\n";
  126. print MAIL "Product    : $product\n";
  127. print MAIL "Version    : $pversion\n";
  128. print MAIL "\n";
  129. print MAIL "O.S.       : $ostype\n";
  130. print MAIL "Version    : $osversion\n";
  131. print MAIL "\n";
  132. print MAIL "Computer   : $computer\n";
  133. print MAIL "Model      : $model\n";
  134. print MAIL "\n";
  135. print MAIL "Middleware : $middleware\n";
  136. print MAIL "\n";
  137. print MAIL "DBase      : $dbase\n";
  138. print MAIL "Version    : $dbversion\n";
  139. print MAIL "\n";
  140. print MAIL "Description:\n";
  141. print MAIL "$description";
  142. print MAIL "\n--end of Support Request form--\n";
  143. close (MAIL);
  144.  
  145.  
  146. print "Support Request Mail Submitted...";
  147.  
  148.